package com.lin.springcloud.service;

import com.lin.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ author:lin tingfeng
 * @ data:2021/10/11-22:50
 */
@Component
public class DeptServiceFallBackFactory implements FallbackFactory {
    @Override
    public DeptService create(Throwable throwable) {
        return new DeptService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public Dept queryDeptById(Long id) {
                return new Dept().setDeptno(id).setDeptname("不存在该用户--Hystrix服务降级返回工厂类方法").setDb_source("No This DATABASE!");
            }

            @Override
            public List<Dept> queryDeptAll() {
                return null;
            }
        };
    }
}
